<?php
require_once('../libraryfiles/config.php');
die;
$content = 'edit_seller.php';
$include = '<script src="' . base_url . 'js/jquery.validate.js" type="text/javascript"></script>
';
require_once TMP_USER_PATH;
/* user data */
$where_user = array(
    Tbluser::id => $_SESSION['acc_id']
);
$user_data = select(Tbluser::Tbluser, '', $where_user);
$result = mysql_fetch_array($user_data);

/* end user data */

/*get company*/
$where_com = array(
		Tblcompany::user_id => $_SESSION['acc_id']
);
$com_data = select(Tblcompany::tblcompany, '', $where_com);
$result_com = mysql_fetch_array($com_data);
/*get company*/
$start = '<span class="coloRed">*</span>';
$error = isset($_GET['error']) ? $_GET['error'] : '';
$success = isset($_GET['success']) ? $_GET['success'] : '';
?>
<script>
    $(document).ready(function() {
        /*Get Disrtict*/
        $("#Phovince").change(function()
        {
            var id = $(this).val();
            var dataString = 'id=' + id;
            var gid = $('option:selected', this).attr('data-id');
            $('#loading').show();
            $.ajax
                    ({
                        type: "POST",
                        url: "<?php echo base_url; ?>account/ajax_district.php?action=byprovince",
                        data: dataString,
                        cache: false,
                        success: function(html)
                        {
                            $("#District").html(html);
                            $("#District").removeAttr("disabled");
                            $('#loading').hide();
                        }
                    });
        });
        /*end Get Disrtict*/
        /*email validate*/
        jQuery.validator.addMethod("email", function(value, element)
        {
            return this.optional(element) || /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/i.test(value);
        }, "<?php echo $lang['EMAILSMSS']; ?>");
        /*end email validate*/
        jQuery.validator.addMethod('integer', function(value, element, param) {
            return this.optional(element) || /^[0-9-+]+$/.test(value);
        }, 'Please enter a non zero integer value!');
        $.validator.addClassRules("required", {
            required: true
        });
        $('#registerForm').validate({
            rules: {
                first_name: "required",
                last_name: "required",
                email: {
                    required: true,
                    email: true
                },
                phone: {
                    integer: true
                },
                address: {
                    required: true
                },
                mobile: {
                    required: true,
                    integer: true
                },
                txt_state: {
                    required: true,
                },
                selectionDistrict: {
                    required: true,
                }
                <?php if($_SESSION['usertype']==2):?>,pharmacy_name: {
                    required: true,
                }
                <?php endif;?>
            },
            messages: {
                first_name: "<?php echo $lang['INPUTFIRSTNAMME']; ?>",
                last_name: "<?php echo $lang['INPUTLASTNAME']; ?>",
                email: "<?php echo $lang['EMAILSMSS']; ?>",
                mobile: "<?php echo $lang['PLEASE_CORRECT_NUMBER']; ?>",
                phone: "<?php echo $lang['PLEASE_CORRECT_NUMBER']; ?>"
            }
        });
    })
</script>

<?php if (!empty($_GET['error'])) { ?>
<div class="row-fluid">
	<div class="span12">
		<?php
		$CURRENT_URL = W_ROOT;
		if (isset($_GET ['error'])) {
                    $message = $_GET ['error'];
                    ?>
		<div class="alert alert-block alert-error fade in">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<h3 class="alert-heading">
				<!--Oh snap! You got an error!-->
				<?php echo $lang['SNAB_ERROO']; ?>
			</h3>
			<p style="font-size: 16px;">
				<blink>
					<?php echo @$lang[$message]; ?>
				</blink>
			</p>
		</div>
		<?php
                }
                ?>
	</div>
</div>
<?php } ?>
<div class="breadcrumb">
    <a class="lever_1" style="z-index:100" href="<?php echo base_url;?>"><?php echo $lang['HOME'];?></a>
    <a class="lever_2" style="z-index:99" href="<?php echo base_url;?>account"><?php echo $lang['SELL_DASH'];?></a>
    <a class="lever_3" style="z-index:98" href="<?php echo base_url;?>account/edit_seller.php"><?php echo $lang['UR_UP_ACCOUNT'];?></a>
</div>
<div class="row-fluid product-info">
    <div class="span2">
        <?php include(S_ROOT . '/templates/sidebar-user.php'); ?>
    </div>
    <div class="span8">
        <div class="box laster custom">
            <div class="box-heading"><h2><?php echo $lang['UR_UP_ACCOUNT']; ?></h2></div>
            <div class="box-content">
                <div class="product-grid" style="padding:10px">
                    <?php
                    if ($success != "") {
                        ?>	
                        <div align="center"><strong style="color:#F00;"><?php echo $success; ?></strong></div>
                        <?php
                    }
                    ?>
                    <?php
                    if ($success != "") {
                        ?>	
                        <div align="center"><strong style="color:#F00;"><?php echo $success; ?></strong></div>
                        <?php
                    }
                    ?>
                    <form name="update" id="registerForm" method="post" enctype="multipart/form-data" action="<?php echo base_url; ?>account/process_register.php?action=edit_user">                        
                        <div class="clear"></div>
                        <input type="hidden" name="backto" value="<?php
                        $backto = @$_GET['backto'];
                        echo ((!empty($backto))?$backto:'');?>"/>
                        <table style="width:100%">
                            <!--<tr height="10"><td></td></tr>-->
                            <tr>
                                <td colspan="3">
                                    <div style="float:left; width:300px;"><span style="color:#417EFB; font-size:18px;"><!--Personal Information--><?php echo $lang['PERSONALINFORR']; ?></span></div>
                                    <div style="float:right;"><span class="coloRed"><!--Note : All (*) are required--><?php echo $lang['NOTESTAR']; ?></span></div>
                                    <input type="hidden" value="<?php echo $result[Tbluser::user_type_id]; ?>" name="accounttype"/>
                                </td>
                            </tr>
                            <!--<tr>
                                <td width="400"><span style="color:#417EFB; font-size:18px;">Personal Information</span></td>
                                <td></td>
                                <td><span class="coloRed">Note : All (*) are required</span></td>
                            </tr>-->
                            <tr>
                                <td><!--First Name--><?php echo $lang['SHIP_FIR_NAME']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td><input type="text" class="b" name="first_name" id="first_name" value="<?php echo $result[Tbluser::first_name]; ?>" onclick="editSeller();"/></td>
                            </tr>
                            <tr>
                                <td><!--Last Name--><?php echo $lang['SHIP_LAS_NAME']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td><input type="text" class="b" name="last_name" id="last_name" value="<?php echo $result[Tbluser::last_name]; ?>" onclick="editSeller();" /></td>
                            </tr>
                            <tr>
                                <td><!--Email--><?php echo $lang['SHIP_EMAIL']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td><input type="text" class="b" name="email" id="email" value="<?php echo $result[Tbluser::email]; ?>" onclick="editSeller();" /></td>
                            </tr>
                            <tr>
                                <td><!--Telephone--><?php echo $lang['SHIP_PHONE']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td><input type="text" class="b" name="phone" id="phone" value="<?php echo $result[Tbluser::phone]; ?>" onclick="editSeller();" /></td>
                            </tr>
                            <tr>
                                <td><!--Mobile--><?php echo $lang['SHIP_MPHONE']; ?></td>
                                <td>:</td>
                                <td><input type="text" class="b" name="mobile" id="mobile" value="<?php echo $result[Tbluser::mobile]; ?>" onclick="editSeller();" /></td>
                            </tr>
                            <tr>
                                <td><!--Address, Street--><?php echo $lang['ADDRESSSTREET']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td><input type="text" class="b" name="address" id="address" value="<?php echo $result[Tbluser::address]; ?>" onclick="editSeller();" /></td>
                            </tr>
                            <tr>
                                <td><!--Country--><?php echo $lang['SHIP_PRO_STATE']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td>
                                    <input type="hidden" value="38" name="country_id"/>                                    
                                    <select name="txt_state" id="Phovince">
                                        <option value=""><?php echo $lang['SHIP_PRO_STATE']; ?></option>
                                        <?php
                                        $tables = Tblprovince::tblprovince;
                                        $province = select($tables);
                                        while ($data = mysql_fetch_array($province)) {
                                            ?>
                                        <option value="<?php echo $data[Tblprovince::id]; ?>" <?php echo($data[Tblprovince::id] == $result[Tbluser::state_id]) ? ' selected="selected"' : '' ?>><?php echo $data[Tblprovince::name]; ?></option>
                                            <?php
                                        }
                                        ?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td><!--Location--><?php echo $lang['LOCATION']; ?><?php echo $start; ?></td>
                                <td>:</td>
                                <td>
                                    <select  name="selectionDistrict" id="District" style="float: left;">
                                        <option value="">District</option>
                                        <?php
                                        $districts = '';
                                        $district = select(Tblstate::tblname);
                                        while ($dis_data = mysql_fetch_assoc($district)) :
                                            ?> 
                                            <option value="<?php echo $dis_data[Tblstate::id]; ?>" <?php echo($dis_data[Tblstate::id] == $result[Tbluser::location]) ? ' selected="selected"' : '' ?>><?php echo $dis_data[Tblstate::name]; ?></option>
                                        <?php endwhile; ?>
                                    </select> 
                                    <div id="loading" style="display: none;"><img src="<?php echo base_url; ?>images/img/colorbox/loading.gif"/></div>
                                </td>
                            </tr>                             
                            <?php if ($usertype == 2): ?>
                                <tr>
                                    <td><!--Postal / Zip Code--><?php echo $lang['SHIP_ZIP_CODE']; ?> <?php echo $start; ?></td>
                                    <td>:</td>
                                    <td><input class="b" value="<?php echo @$result['zip'] ?>" type="text" name="zip" id="txtShippingPostalCode" onblur="sh_zip()" onclick="editSeller();" /></td>
                                </tr>
                                <tr height="60">
                                    <td colspan="3">
                                        <div style="margin-top:30px;"><span style="color:#417EFB; font-size:18px;"><!--Company Infomation--><?php echo $lang['COMPANYINFO']; ?></span></div>
                                    </td>
                                </tr>

                                <tr>
                                    <td><!--Company Name--><?php echo $lang['COMPANYNAMEE']; ?><?php echo $start; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_name" id="pharmacy_name" value="<?php echo @$result_com['pharmacy_name'] ?>" onclick="editSeller();" /></td>
                                </tr>
                                <tr>
                                    <td><!--Logo--><?php echo $lang['LOGO']; ?></td>
                                    <td>:</td>
                                    <td>
                                        <!--<form action="#" method="post" enctype="multipart/form-data">
                                            <input type="file" name="image" id="file" />
                                            
                                        </form>-->
                                        <input type="file" class="b" name="logo_image" id="file" />                        
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td></td>
                                    <td><?php
                                        if (@$result_com['pharmacy_image'] != "") {
                                            ?>	
                                            &nbsp;<img src="<?php echo base_url; ?>account/upload/<?php echo @$result_com['pharmacy_image']; ?>" class="border" />
                                            <?php
                                        } else {
                                            echo $lang['NOIMAGESS'];
                                        }
                                        ?>

                                    </td>
                                </tr>
                                <!--<tr>
                                    <td><?php echo $lang['ADDRSELLER']; ?><?php echo $start; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_address" id="pharmacy_address" value="<?php echo @$result_com['paddress']; ?>" onclick="editSeller();" /></td>
                                </tr>                            
                                <tr>
                                    <td><?php echo $lang['SHIP_PHONE']; ?><?php echo $start; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_phone" id="pharmacy_phone" value="<?php echo @$result_com['pphone']; ?>" onclick="editSeller();" /></td>
                                </tr>
                                <tr>
                                    <td><?php echo $lang['FAX']; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_fax" value="<?php echo @$result_com['fax']; ?>" onclick="editSeller();" /></td>
                                </tr>
                                 <tr>
                                    <td><?php echo $lang['SHIP_EMAIL']; ?><?php echo $start; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_email" id="pharmacy_email" value="<?php echo @$result_com['pemail']; ?>" onclick="editSeller();" /></td>
                                </tr>-->
                                <tr>
                                    <td><!--Website--><?php echo $lang['WEBSITE']; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_website" value="<?php echo @$result_com['website']; ?>" onclick="editSeller();" /></td>
                                </tr>
                                <tr>
                                    <!-- <td><?php echo $lang['LICENSES']; ?><?php echo $start; ?></td>
                                    <td>:</td>
                                    <td><input type="text" class="b" name="pharmacy_license" value="<?php echo @$result_com['license']; ?>" onclick="editSeller();" /></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td></td>
                                    <td>
                                        <input type="checkbox" class="b" name="newsletter" value="1" />	<?php echo $lang['RCIEVENEW']; ?>
                                    </td>
                                </tr>-->
                            <?php endif; ?>
                            <tr>
                                <td></td>
                                <td></td>
                                <td>
                                    <input type="submit" value="Update your Profile" name="edit" class="btn btn-warning pull-right" />
                                </td>
                            </tr>
                        </table>

                        <div style="margin-top: 10px"></div>
                    </form>
                    <div class="clear"></div>
                </div>                  
            </div>            
        </div>
    </div>

    <div class="span2">
        <?php include(S_ROOT . '/templates/sidebar-right.php'); ?>
    </div>
</div>
